//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.lyq.bean.service;

import com.lyq.bean.Course;
import com.lyq.bean.Teacher;
import com.lyq.bean.mySql.AddT_Sql;
import com.lyq.bean.mySql.RemoveT_Sql;
import com.lyq.bean.mySql.SeekAllT_Sql;
import com.lyq.bean.mySql.SeekExist_Sql;
import com.lyq.bean.mySql.SeekT_Sql;
import com.lyq.bean.mySql.UpdateTInfo_Sql;
import java.util.List;

public class T_Service {
    public T_Service() {
    }

    public Boolean add_T(String No, String name, String sex, String age, String collage, String pwd) {
        Boolean bool = (new SeekExist_Sql()).seekExist_Sql(No, "教师");
        if (bool) {
            bool = false;
        } else {
            bool = (new AddT_Sql()).addS_Sql(No, name, sex, age, collage, pwd);
        }

        return bool;
    }

    public List<Teacher> seekAll_T(List<Teacher> list) {
        List<Teacher> lt = (new SeekAllT_Sql()).seekAllT_Sql(list);
        return lt;
    }
    public String remove_T_With_Message(String tNo) {
        // 检查教师是否正在授课
        List<Course> list = (new TC_Service()).getTeachC(tNo);

        // 如果有授课，则不允许删除
        if (list.size() > 0) {
            return "无法删除，该教师正在授课，请先将课程分配给其他教师后再删除";
        }

        // 如果没有授课，则可以删除
        Boolean bool = (new RemoveT_Sql()).removeT_Sql(tNo);
        if (bool) {
            return "删除成功！";
        } else {
            return "删除失败！";
        }
    }


    public List<Teacher> seek_T(String select, String seek, String name, List<Teacher> list) {
        if (select.equals("工号")) {
            select = "T_No";
        } else if (select.equals("姓名")) {
            select = "T_Name";
        } else if (select.equals("所在学院")) {
            select = "T_Collage";
        }

        List<Teacher> lt = (new SeekT_Sql()).seekT_Sql(select, seek, name, list);
        return lt;
    }

    public Boolean updateteacherInfo(String No, String name, String sex, String age, String collage, String pwd) {
        Boolean bool = (new UpdateTInfo_Sql()).updateTInfo_Sql(No, name, sex, age, collage, pwd);
        return bool;
    }
}
